package com.bbyb.operating.examination.controller;

import com.bbyb.operating.examination.model.po.RoleUser;
import com.bbyb.operating.examination.model.vo.CommonResult;
import com.bbyb.operating.examination.service.RoleUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: RoleUserController
 * @Description: 角色与账号关联控制器
 * @Author: ZengFz
 * @Date: 2024/5/4 9:10:53
 */
@RestController
@Api(tags = "角色与账号关联")
@Slf4j
public class RoleUserController {

    @Autowired
    private RoleUserService roleUserService;

    /**
     * 新增角色与账号关联
     *
     * @param roleUser 角色与账号关联信息
     * @return CommonResult<String> 新增结果
     */
    @PostMapping("/role-users")
    @ApiOperation("新增角色与账号关联")
    public CommonResult<String> addRoleUser(@RequestBody RoleUser roleUser) {
        roleUserService.addRoleUser(roleUser);
        return new CommonResult<>();
    }

    /**
     * 删除角色与账号关联
     *
     * @param id 角色与账号关联ID
     * @return CommonResult<String> 删除结果
     */
    @DeleteMapping("/role-users/{id}")
    @ApiOperation("删除角色与账号关联")
    public CommonResult<String> deleteRoleUser(@PathVariable Long id) {
        roleUserService.deleteRoleUser(id);
        return new CommonResult<>();
    }
}
